<div class="main-container" id="main-container">
    <div class="main-container-inner">
        <div class="main-content">
            <div class="page-content">
                <div class="row">
                    <!--<div class="col-xs-12">-->
                    <form class="form-horizontal" role="form" id="add_form">

                        <div class="col-md-12" style="display: none">
                            <div class="form-group">
                                <label for="name" class="col-sm-3 control-label">姓名</label>
                                <div class="col-sm-7">
                                    <input type="text" class="form-control" id="name" name="name" value="刘晓龙">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="form-group">
                                <label for="contentThings" class="col-sm-3 control-label">主要事情</label>
                                <div class="col-sm-7">
                                    <input type="text" class="form-control" id="contentThings" name="contentThings">
                                </div>
                            </div>
                        </div>
                        <div class="form-group" style="display: none">
                            <label for="agreementStartDate" class="col-sm-3 control-label">开始时间</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" id="agreementStartDate" name="startTime">
                            </div>
                        </div>
                        <div class="form-group" style="display: none">
                            <label for="agreementEndDate" class="col-sm-3 control-label">结束时间</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" id="agreementEndDate" name="endTime">
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="form-group">
                                <label for="en_date1" class="col-sm-3 control-label">起始-终止时间</label>
                                <div class="col-sm-7">
                                    <input type="text" class="form-control" id="en_date1">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="form-group">
                                <label for="consumeTime" class="col-sm-3 control-label">消耗时间(分钟)</label>
                                <div class="col-sm-7">
                                    <input type="text" class="form-control" id="consumeTime" name="consumeTime">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="form-group">
                                <label for="why" class="col-sm-3 control-label">此事的初衷及实现</label>
                                <div class="col-sm-7">
                                    <textarea type="text" class="form-control" id="why" name="why"></textarea>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="form-group">
                                <label for="hinderSolve" class="col-sm-3 control-label">遇到的阻碍及办法</label>
                                <div class="col-sm-7">
                                    <textarea type="text" class="form-control" id="hinderSolve" name="hinderSolve"></textarea>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="form-group">
                                <label for="gain" class="col-sm-3 control-label">收获</label>
                                <div class="col-sm-7">
                                    <textarea type="text" class="form-control" id="gain" name="gain"></textarea>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="form-group">
                                <label for="additionalThings" class="col-sm-3 control-label">附加事情</label>
                                <div class="col-sm-7">
                                    <!--<textarea type="text" class="form-control" id="additionalThings" name="additionalThings"></textarea>-->
                                    <input type="text" class="form-control" id="additionalThings" name="additionalThings">
                                </div>
                            </div>
                        </div>
                        <!--<div class="col-md-12">-->
                        <!--<div class="form-group">-->
                        <!--<label for="nextThing" class="col-sm-3 control-label">下一件要做的事情</label>-->
                        <!--<div class="col-sm-7">-->
                        <!--<input type="text" class="form-control" id="nextThing" name="nextThing">-->
                        <!--</div>-->
                        <!--</div>-->
                        <!--</div>-->

                    </form>
                    <!--</div>-->
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(document).on("input propertychange", "textarea", function (e) {
        var target = e.target;
        // 保存初始高度，之后需要重新设置一下初始高度，避免只能增高不能减低。
        var dh = $(target).attr('defaultHeight') || 0;
        if (!dh) {
            dh = target.clientHeight;
            $(target).attr('defaultHeight', dh);
        }

        target.style.height = dh +'px';
        var clientHeight = target.clientHeight;
        var scrollHeight = target.scrollHeight;
        if (clientHeight !== scrollHeight) { target.style.height = scrollHeight + 10 + "px";
        }
    });
    $(function () {
        var date = new Date();
        var nextMonthDay = new Date(date.getFullYear(), date.getMonth() + 1, date.getDate() + 1);
        $('#en_date1').daterangepicker({
            timePicker: true, //显示时间
            timePicker24Hour: true, //时间制
            timePickerSeconds: false, //时间显示到秒
            startDate: moment(new Date()), //设置开始日期
            endDate: moment(new Date()), //设置结束器日期
            maxDate: moment(nextMonthDay), //设置最大日期
            opens: "center",
            drops: "down",
            /* singleDatePicker: true, //单日历*/
            locale: d_locale,
        }, function (start, end, label) {
            var timeRangeChange = [start.format('YYYY-MM-DD HH:mm:ss'), end.format('YYYY-MM-DD HH:mm:ss')];
            $("#agreementStartDate").val(start.format('YYYY-MM-DD HH:mm:ss'))
            $("#agreementEndDate").val(end.format('YYYY-MM-DD HH:mm:ss'))
            //算消耗多少分钟(四舍五入)
            $("#consumeTime").val(Math.round((end-start)/60000));
        });
    })

    function form_sub() {
        ajaxs('./MDiary/add', 'POST', $("#add_form").serialize(), true, function (data) {
            layer.msg("成功");
            $("#BannerTable table").bootstrapTable('refresh');
            $("#im_unique_dlg").modal('hide');
        });
    }
</script>
